<head>
    <meta charset="utf-8">
    <title>随访档案详情</title>
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
    </script>
    <script src="../../js/basic-load.js" charset="utf-8"></script>
    <script src="../../lib/layui-v2.6.3/layui.js"></script>
    <!-- <link rel="stylesheet" hrf="../../css/public.css" media="all"> -->
</head>
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
    <ul class="layui-tab-title">
        <li class="layui-this" id="tt1">病例档案</li>
        <li>随访记录</li>
        <li id="tt3">记录标注</li>
        <li>档案账号管理</li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show" id="t1">
            <div id = "item_1"></div>
        </div>
        <div class="layui-tab-item">
            <div id = "item_2"></div>
        </div>
        <div class="layui-tab-item" id="t3">
            <div id = "item_3"></div>
        </div>
        <div class="layui-tab-item">
            <div id = "item_4"></div>
        </div>
    </div>
</div>

<script>
    
    //注意：选项卡 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function () {
        var element = layui.element;

        var directgotolabel=sessionStorage.getItem("directgotolabel")
        if(directgotolabel==1){
            sessionStorage.removeItem("directgotolabel");
            $("#t1").removeClass("layui-show")
            $("#t3").addClass("layui-show")
            $("#tt1").removeClass("layui-this")
            $("#tt3").addClass("layui-this")

        }
        //…
    });
    function setData(data, privilege){
        $("#item_1").load('detail.html',function(response,status){
            if (status=="success"){
                setDataDetail(data, privilege)
            }
        })
        $("#item_2").load('follow.html',function(response,status){
            if (status=="success"){
                setDataFollow(data, privilege)
            }
        })

        //第一次我想的是默认给最新的随访记录的相关信息，所以要了一个新接口,
        //这个接口要的数据格式和http://127.0.0.1:8007/followRecord/getOne是一样的，
        //但是我传的是档案id，要的是这个档案的最新的随访记录相关信息
        $("#item_3").load('follow_record_label.html',function(response,status){
            if (status=="success"){
                var mrId=data.id
                $.ajax({
                    url: `${url_basic}/followRecord/followlabel`,
                    type: "POST",
                    // url:'/api/follow_detail.json',
                    // method: 'get',
                    data:JSON.stringify({"mrId":data.id}),    //向后端传递档案的id
                    contentType:'application/json',
                    success: function (data, textStatus) {
                        setDataLable(data,mrId,privilege)
                    },
                    error: function (xhr, errorText, errorType) {
                        layer.msg('获取待标注记录失败（与服务器连接失败）');
                    },
                    dataType: "json"
                })
 
            }
        })
    
    
    
        $("#item_4").load('manage.html',function(response,status){
            if (status=="success"){
                setDataManage(data.id, privilege)
            }
        })
    
    }
    
</script>